﻿using UnityEngine;
using System.Collections;

public class DoorUpDown_Auto : MonoBehaviour
{
    public float MinY, MaxY;
    public float DoorSpeed;
    float dir, offest, range;
    private void Awake()
    {
        dir = 1f;
        offest = 0f;
        range = MaxY - MinY;
    }
    void Update()
    {
        float step = DoorSpeed * Time.deltaTime * dir;
        offest += step;
        if (offest >= range) dir = -1f;
        else if (offest <= 0f) dir = 1f;
        transform.Translate(0f, step, 0f);
    }
}
